package com.cysyz.mylib.utils.tree.impl;

import com.cysyz.mylib.utils.tree.TreeAble;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class TreeAbleImpl<T extends TreeAble, E extends Serializable> implements TreeAble<T, E> {
	/**
	 *自身id
	 */
	private E id;
	/**
	 * 父id
	 */
	private E pid;
	/**
	 * 节点内容
	 */
	private Object data;

	private List<T> children = new ArrayList<T>();


	public TreeAbleImpl() {
	}

	@Override
	public E getId() {
		return id;
	}

	public void setId(E id) {
		this.id = id;
	}

	@Override
	public E getPid() {
		return pid;
	}

	public void setPid(E pid) {
		this.pid = pid;
	}


	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	@Override
	public void addChild(T node) {
		this.children.add(node);
	}

	@Override
	public boolean hasParent() 	{
		return this.getPid() != null && !this.getPid().equals("");
	}
}